package com.woniuxy02;

/**
 * @author 作者
 * @create 2025-06-23 15:37
 */
public class RunnableThread implements Runnable {

    int num = 100;

    @Override
    public void run() {
        while (true) {
            try {
                //线程休眠，运行到这里会停止100毫秒.模拟网络拥堵，高并发
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (this) {
                if (num > 0) {
                    System.out.println(Thread.currentThread().getName() + "窗口售出,还剩" + (--num));
                }
            }
        }
    }
}
